package org.mii.safeguard_v1.security.dao;

import java.util.List;

import org.mii.safeguard_v1.security.entity.Resource;
import org.springframework.stereotype.Repository;
import org.springside.modules.orm.hibernate.HibernateDao;

@Repository
public class ResourceDao extends HibernateDao<Resource, Integer> {
	public static final String QUERY_BY_RESOURCETYPE_WITH_AUTHORITY = "from Resource r left join fetch r.authorities WHERE r.resourceType=? ORDER BY r.position ASC";

	@SuppressWarnings("unchecked")
	public List<Resource> getUrlResourceWithAuthorities() {
		return distinct(
				createQuery(QUERY_BY_RESOURCETYPE_WITH_AUTHORITY,
						Resource.URL_TYPE)).list();
	}
}
